package com.pvdnc.riru;

import android.util.Log;

import com.pvdnc.riru.app.HookApplications;
import com.pvdnc.riru.common.ServiceObserver;
import com.pvdnc.riru.common.ServiceObserverManager;
import com.pvdnc.riru.system_server.HookActivityManagerService;
import com.pvdnc.riru.system_server.HookBatteryStatsService;
import com.pvdnc.riru.system_server.HookNetworkStatService;
import com.pvdnc.riru.system_server.HookPackageManagerService;
import com.pvdnc.riru.system_server.HookServiceManager;

import static android.os.Build.VERSION.SDK_INT;
import static android.os.Build.VERSION_CODES.M;

public class Riru {
    private static final String TAG=Riru.class.getSimpleName();
    public static void start(){
        Log.d(TAG,"enter Riru java part");
        if (SDK_INT >= M) {
            //hook系统服务
            ServiceObserverManager.INSTANCE.addObserver("package", HookPackageManagerService.INSTANCE);
            ServiceObserverManager.INSTANCE.addObserver("batterystats", HookBatteryStatsService.INSTANCE);
            ServiceObserverManager.INSTANCE.addObserver("netstats", HookNetworkStatService.INSTANCE);
        }
        HookServiceManager.INSTANCE.hookAll();

        HookApplications.INSTANCE.hookAll();
    }
}
